<?php defined('SYSPATH') or die('No direct script access.');

class Model_Dao_Analysis extends ORM{

	protected $_table_name  = 'analysis'; // default: accounts
    protected $_primary_key = 'id';      // default: id
    protected $_primary_val = 'analysis_date';      // default: name (column used as primary value)
    
	// default for $_table_columns: use db introspection to find columns and info
    // see http://v3.kohanaphp.com/guide/api/Database_MySQL#list_columns for all possible column attributes
    protected $_table_columns = array(
        'id'   => array('data_type' => 'int',    'is_nullable' => FALSE),
    	'patient_id' => array('data_type' => 'int',    'is_nullable' => FALSE), 
        'medic_id'  => array('data_type' => 'int', 'is_nullable' => TRUE),
    	'creation_date' => array('data_type'=>'date', 'is_nullable' => FALSE),
    	'analysis_date' => array('data_type' => 'date',    'is_nullable' => FALSE), 
        'file_name'  => array('data_type' => 'string', 'is_nullable' => TRUE),
    	'raw_signal_id' => array('data_type'=>'int', 'is_nullable' => FALSE),
    	'analysis_result_id' => array('data_type' => 'int',    'is_nullable' => TRUE), 
        'report_id'  => array('data_type' => 'int', 'is_nullable' => TRUE),
    	'final_segment_id' => array('data_type'=>'int', 'is_nullable' => TRUE),
    	'period_id' => array('data_type' => 'int',    'is_nullable' => FALSE), 
        'clinical_info_id'  => array('data_type' => 'int', 'is_nullable' => TRUE),
    	'include_in_stats' => array('data_type' => 'int', 'is_nullable' => TRUE)
    );

    //Relaciones
    protected $_belongs_to = array(
    							'clinical_information'=>array('model'=>'dao_clinicalinformation','foreign_key'=>'clinical_info_id'),
    							'final_segment'=>array('model'=>'dao_finalsegments','foreign_key'=>'final_segment_id'),
    							'medic'=>array('model'=>'dao_medic','foreign_key'=>'medic_id'),
    							'period'=>array('model'=>'dao_samplingperiod','foreign_key'=>'period_id'),
    							'patient'=>array('model'=>'dao_patient','foreign_key'=>'patient_id'),
    							'raw_signal'=>array('model'=>'dao_rawsignal','foreign_key'=>'raw_signal_id'),
    							'result'=>array('model'=>'dao_analysisresult','foreign_key'=>'analysis_result_id'),
    							'report'=>array('model'=>'dao_report','foreign_key'=>'report_id')
    						);
	

}?>